package com.wang.tasker.core;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

import org.dom4j.Element;


public class ElementList implements List {
	
	private List list;
	
	public ElementList(List list){
		this.list = list;
	}

	@Override
	public int size() {
		return list.size();
	}

	@Override
	public boolean isEmpty() {
		return list.isEmpty();
	}

	@Override
	public boolean contains(Object o) {
		if(o instanceof ConfigElement)
			return list.contains(o);
		return false;
	}

	@Override
	public Iterator iterator() {
		return list.iterator();
	}

	@Override
	public Object[] toArray() {
		return list.toArray();
	}

	@Override
	public Object[] toArray(Object[] a) {
		return list.toArray(a);
	}

	@Override
	public boolean add(Object e) {
		return list.add(e);
	}

	@Override
	public boolean remove(Object o) {
		return list.remove(o);
	}

	@Override
	public boolean containsAll(Collection c) {
		return list.containsAll(c);
	}

	@Override
	public boolean addAll(Collection c) {
		//this function is not work for this class
		return false;
	}

	@Override
	public boolean addAll(int index, Collection c) {
		//this function is not work for this class
		return false;
	}

	@Override
	public boolean removeAll(Collection c) {
		//this function is not work for this class
		return false;
	}

	@Override
	public boolean retainAll(Collection c) {
		//this function is not work for this class
		return false;
	}

	@Override
	public void clear() {
		list.clear();
	}

	@Override
	public Object get(int index) {
		return list.get(index);
	}

	@Override
	public Object set(int index, Object element) {
		if(element instanceof ConfigElement)
			list.set(index, element);
		return null;
	}

	@Override
	public void add(int index, Object element) {
		if(element instanceof ConfigElement)
			list.set(index, element);
	}

	@Override
	public Object remove(int index) {
		return list.remove(index);
	}

	@Override
	public int indexOf(Object o) {
		if(o instanceof ConfigElement)
			return list.indexOf(o);
		return -1;
	}

	@Override
	public int lastIndexOf(Object o) {
		if(o instanceof ConfigElement)
			return list.indexOf(o);
		return -1;
	}

	@Override
	public ListIterator listIterator() {
		return list.listIterator();
	}

	@Override
	public ListIterator listIterator(int index) {
		return list.listIterator(index);
	}

	@Override
	public List subList(int fromIndex, int toIndex) {
		return list.subList(fromIndex, toIndex);
	}

}
